package com.upf1sh.mapper;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.upf1sh.bean.FileEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

@Mapper
@Repository
@TableName("file")
public interface FileMapper extends BaseMapper<FileEntity> {

    @Delete("Delete from file where path=#{path}")
    int deleteFile_entity(String path);

    /**
     * 获取上传者
     * UpF1sh
     * 2023/4/20 21:41
     *
     * @return
     */
    @Select("Select distinct file.belong from file")
    String[] Owner();

    /**
     * 获取上传者
     * UpF1sh
     * 2023/4/20 21:41
     *
     * @return
     */
    @Select("select distinct file.date from file")
    Long[] Days();

    @Select("select * from file where name=#{fileName}")
    FileEntity findByFileName(String fileName);

    /**
     * 根据文件路径查询文件信息
     * 2023/5/4 14:33
     *
     * @param path
     * @return
     */
    @Select("select * from file where path=#{path}")
    FileEntity findByPath(String path);

}
